package io.adminboot.service.impl;

import io.adminboot.domain.vo.PageVO;
import io.adminboot.entity.ScheduleJobLog;
import io.adminboot.repository.extend.ScheduleJobLogExtMapper;
import io.adminboot.service.ScheduleJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl implements ScheduleJobLogService {

	@Autowired
	private ScheduleJobLogExtMapper mapper;
	
	@Override
	public PageVO queryPage(Long jobId, Integer pageNum, Integer pageSize) {
		List<ScheduleJobLog> list = mapper.selectList(jobId, (pageNum - 1) * pageSize, pageSize);
		int totalCount = mapper.count(jobId);
		PageVO page = new PageVO(list, totalCount, pageSize, pageNum);
		return page;
	}

	@Override
	public void insert(ScheduleJobLog log) {
		mapper.insert(log);
	}

	@Override
	public ScheduleJobLog selectById(Long id) {
		return mapper.selectByPrimaryKey(id);
	}

}
